<CFSET dDate = DATEFORMAT(Now(),"mm/dd/yyyy")> 
<CFMODULE TEMPLATE="#client.common_path#cfm_DBdateFormat.cfm" dateConvert="#dDate#">
<CFSET sDate1 = dateResult>

<CFMODULE TEMPLATE="#client.common_path#cfm_DBdateFormat.cfm" dateConvert="#GetRecord.REFERENCEDATE#">
<CFSET sDate2 = dateResult>

<CFSET sMessPostApproval="Employee's request for Log In/Out has been reflected to BOS/e.">
<CFQUERY NAME="qryCINTKEXCEPTEVENTI" DATASOURCE="#client.company_dsn#">
	SELECT *
	FROM CINTKEXCEPTEVENTI
	WHERE ROUTEID = '#GetRecord.ROUTEID#'
</CFQUERY>

<CFIF qryCINTKEXCEPTEVENTI.RecordCount>
	<!--- Check for record existence --->
	<CFQUERY NAME="qryCINTKEXCEPTEVENT" DATASOURCE="#client.company_dsn#">
		SELECT *
		FROM CINTKEXCEPTEVENT
		WHERE PERSONNELIDNO = '#GetRecord.PERSONNELIDNO#' AND
			  REFERENCEDATE = #preserveSingleQuotes(sDate2)# AND
			  EVENTTIME = '#GetRecord.EVENTTIME#' AND
			  EVENTTYPE = '#GetRecord.EVENTTYPE#'
	</CFQUERY>

	<CFIF NOT qryCINTKEXCEPTEVENT.RecordCount>
		<CFTRANSACTION>
		<CFTRY>
			<CFQUERY NAME="qryNoInOut" DATASOURCE="#client.company_dsn#">
				INSERT INTO CINTKEXCEPTEVENT
					(PERSONNELIDNO, REFERENCEDATE,
					 EVENTTIME, EVENTTYPE, REMARKS,
					 RECCREATEDBY, RECDATECREATED, USERID,
					 DATELASTUPDATE, TIMELASTUPDATE)
				VALUES
					('#GetRecord.PERSONNELIDNO#', #preserveSingleQuotes(sDate2)#,
					 '#GetRecord.EVENTTIME#', '#GetRecord.EVENTTYPE#', '#GetRecord.REMARKS#',
					 '#client.userid#', #preserveSingleQuotes(sDate1)#, '#client.userid#',
					 #preserveSingleQuotes(sDate1)#')
			</CFQUERY>

			<CFQUERY NAME="qryNoInOutM" DATASOURCE="#client.company_dsn#">
				INSERT INTO CINTKEXCEPTEVENTM
					(REFERENCEDATE,
					 EVENTTIME, EVENTTYPE, REMARKS,
					 RECCREATEDBY, RECDATECREATED, USERID,
					 DATELASTUPDATE, TIMELASTUPDATE)
				VALUES
					#preserveSingleQuotes(sDate2)#,
					'#GetRecord.EVENTTIME#', '#GetRecord.EVENTTYPE#', '#GetRecord.REMARKS#',
					'#client.userid#', #preserveSingleQuotes(sDate1)#, '#client.userid#',
					#preserveSingleQuotes(sDate1)#')
			</CFQUERY>

			<CFTRANSACTION ACTION="COMMIT"/>
			<CFCATCH TYPE="Database">
				<CFTRANSACTION ACTION="ROLLBACK"/>
				<CFSET sMessPostApproval="Error in post-approval activity ...<br><br>#CFCATCH.message# #CFCATCH.DETAIL#">
			</CFCATCH>
		</CFTRY>
		</CFTRANSACTION>
	<CFELSE>
		<CFSET sMessPostApproval="ERROR!!! Request already exists in BOS/e.">
	</CFIF>	<!--- Training Event not found in CINTRNGEVENT --->
<CFELSE>
	<CFSET sMessPostApproval="WARNING!!! Unable to post request for Log In/Out. Application form is missing.<BR>Please contact your administrator.">
</CFIF> <!--- RouteID not found in CINTRAINING --->